package com.tangweiliang.springboot;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * @author :tangweiliang
 * @date : 2022/12/30 16:57
 * 未来的你会感谢现在努力的自己
 */
@Configuration
public class WebServerAutoConfiguration implements AutoConfiguration{

    @Bean
    //@Conditional(TangweiliangCondition.class) // springframework的条件注解  满足一定条件这个bean才可以生效
    @ConditionalOnClass("org.apache.catalina.startup.Tomcat")
    public TomcatWebServer tomcatWebServer(){
        return new TomcatWebServer();
    }

    @Bean
    @ConditionalOnClass("org.eclipse.jetty.server.Server")
    public JettyWebServer jettyWebServer(){
        return new JettyWebServer();
    }

}
